#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
#define P pair<int,int>
#define px first
#define py second
int n,m,L,V,T,d[N],v[N],a[N],p[N],f[N];
inline int read(){
    int x=0,flg=1;
    char ch;
    while(!isdigit(ch=getchar())) if(ch=='-') flg=-1;
    while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    return x*flg;
}
inline int getr(const int& x){
    return upper_bound(p+1,p+m+1,x)-p-1;
}
inline int getl(const int& x){
    return lower_bound(p+1,p+m+1,x)-p;
}
inline int c_devide(const int& x,const int& y){
    //return ceil(double(x)/y);
    return x%y?x/y+1:x/y;
}
vector<int> g[N];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--){
        n=read(),m=read(),L=read(),V=read();
        for(int i=0;i<=n;i++) g[i].clear();
        for(int i=1;i<=n;i++) d[i]=read(),v[i]=read(),a[i]=read();
        for(int i=1;i<=m;i++) p[i]=read();
        int cnt=0;
        L=p[m];
        for(int i=1;i<=n;i++){
            if(d[i]>L){
                ++cnt;
                continue;
            }
            if(a[i]==0){
                if(v[i]>V) g[getl(d[i])].emplace_back(m);
                else ++cnt;
            }
            else if(a[i]>0){
                if(v[i]>V){
                    g[getl(d[i])].emplace_back(m);
                    continue;
                }
                int l=getl(d[i]+(V*V-v[i]*v[i])/(2*a[i])+1),r=m;
                if(l>r) ++cnt;
                else g[l-1].emplace_back(r);
                //cerr<<"Range:("<<d[i]+double(V*V-v[i]*v[i])/(2*a[i])<<",INF]\n";
                //,cerr<<i<<":"<<l<<" "<<r<<endl;
            }
            else{
                if(v[i]<=V){
                    ++cnt;
                    continue;
                }
                int l=getl(d[i]),r=getr(d[i]+c_devide(v[i]*v[i]-V*V,2*-a[i])-1);
                if(l>r) ++cnt;
                else g[l-1].emplace_back(r);
                //cerr<<"Range:["<<d[i]<<","<<d[i]+double(V*V-v[i]*v[i])/(2*a[i])<<")\n";
                //,cerr<<i<<":"<<l<<" "<<r<<endl;
            }
        //cerr<<i<<" "<<cnt<<endl;
        }
        memset(f,0,sizeof f);
        for(int i=0;i<m;i++){
            f[i+1]=max(f[i+1],f[i]);
            for(int j:g[i]) f[j]=max(f[j],f[i]+1);
        }
        //for(int i=1;i<=m;i++) if(f[i]>f[i-1]) cerr<<p[i]<<" ";cerr<<endl;
        printf("%d %d\n",n-cnt,m-f[m]);
    }
    return 0;
}
